package com.example.competionmanagebackend.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.competionmanagebackend.entity.Announcements;
import com.example.competionmanagebackend.mapper.AnnouncementsMapper;
import com.example.competionmanagebackend.service.AnnouncementsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AnnouncementsServiceImpl extends ServiceImpl<AnnouncementsMapper, Announcements>
        implements AnnouncementsService {

    @Resource
    private AnnouncementsMapper announcementsMapper;

    @Override
    public Page<Announcements> getAnnouncementsPage(int currentPage, int pageSize) {
        Page<Announcements> page = new Page<>(currentPage, pageSize);
        return this.page(page);
    }

    @Override
    public void insertAnnouncement(Announcements announcement) {
        announcementsMapper.insertAnnouncement(announcement);
    }

    @Override
    public void updateAnnouncement(Announcements announcement) {
        announcementsMapper.updateAnnouncement(announcement);
    }

    @Override
    public void deleteAnnouncement(Integer id) {
        announcementsMapper.deleteAnnouncementById(id);
    }
}